#ifndef __PWHDR_BARRIER_HPP__
#define __PWHDR_BARRIER_HPP__

#include "threadobject.hpp"

namespace purewell
{

class PWBarrierAttribute;

//! \brief Barrier object.
class PWBarrier : public PWThreadObject
{
public:
	//! \brief Create barrier.
	//! \param[in] count Thread count to wait.
	//! \param[in] pattr Attribution.
	//! \return On success, barrier pointer or NULL.
	static PWBarrier* create(size_t count,
		const PWBarrierAttribute* pattr = NULL);

	//! \brief Release barrier.
	//! \param[in] obj Barrier object to release.
	static void release(PWBarrier* obj);

public:
	//! \brief Wait for threads.
	//! \return On success, true.
	bool wait(void);

private:
	explicit PWBarrier(size_t count, const PWBarrierAttribute* pattr);
	virtual ~PWBarrier();
};

//! \brief Barrier attribution object.
class PWBarrierAttribute : public PWThreadObject
{
public:
	//! \brief Create barrier attribution.
	//! \return On success, barrier attribution pointer or NULL.
	static PWBarrierAttribute* create(void);

	//! \brief Release barrier attribution.
	//! \param[in] obj Barrier attribution object to release.
	static void release(PWBarrierAttribute* obj);

private:
	explicit PWBarrierAttribute();
	virtual ~PWBarrierAttribute();
};

};

#endif//!__PWHDR_BARRIER_HPP__

